home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-06-23 | 1.6 KB | 75 lines | [TEXT/MPS ] |
- Program Ext_AreaButton;
-
- Uses MemTypes, QuickDraw, OSIntf,
- ToolIntf, PackIntf;
-
- Const
- InitEvt=16;
- DeInitEvt=17;
-
- Type
- {This is the definition of the data}
- {structure I want to use. All I want}
- {to know is if the Mouse was clicked}
- {in the external area. 0 if NO,}
- {1 if YES.}
- MyData = record
- Status:Integer;
- end;
- MyDataPtr = ^ MyData;
- MyDataHndl = ^MyDataPtr;
-
- Var
- AreaEv:EventRecord;
- AreaRec:Rect;
- AreaNam:str255;
- AreaHnd:MyDataHndl;
-
- procedure AreaButton(
- var AreaEvent:EventRecord;
- var AreaRect:Rect;
- var AreaName:str255;
- var AreaHndl:MyDataHndl);
-
- var tPoint:Point; {Tracks the mouse location.}
-
- begin
- Case AreaEvent.What of
- InitEvt:
- begin
- {Create a new handle for our}
- {structure.}
- AreaHndl:=MyDataHndl(NewHandle(
- sizeof(MyData)));
- {Initialize the setting to 0. Not}
- {clicked.}
- AreaHndl^^.Status:=0;
- end; {InitEvt}
- MouseDown:
- begin
- {Wait for mouse up so we know they}
- {completed the click within our}
- {area and didn't drag out of the}
- {area before releasing.}
- While StillDown do begin end;
- {Is the mouse in our area?}
- GetMouse(tPoint);
- {AreaRect is our rect so test if the}
- {point is in our area.}
- if(PtInRect(tPoint, AreaRect)) then
- {They clicked in our area so}
- {Status=1. Clicked}
- AreaHndl^^.Status:=1;
- end; {MouseDown}
- DeInitEvt:
- begin {Get rid of our handle}
- DisposHandle(Handle(AreaHndl));
- end; {DeInitEvt}
- end; {Case AreaEvent.What}
- end; {AreaButton}
-
- Begin
- AreaButton(AreaEv, AreaRec, AreaNam,
- AreaHnd);
- End. {Main Block}
-